package com.jcdd.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jcdd.object.db.User;
import com.jcdd.object.front.HomeFirstGoodsFO;
import com.jcdd.object.front.OtherUserInfoFO;
import com.jcdd.object.front.OwnUserInfoFO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("select name, avatar_url from user where user_id = #{userId}")
    OtherUserInfoFO getOtherUserInfo(Long userId);

    @Select("select name, avatar_url, mail from user where user_id = #{userId} and status = 1")
    OwnUserInfoFO getOwnUserInfo(Long userId);

    @Update("update user set avatar_url=#{newAvatarUrl} where user_id = #{userId}")
    int setAvatarUrl(Long userId, String newAvatarUrl);

    @Update("update user set name=#{newName} where user_id = #{userId}")
    int setName(Long userId, String newName);

    @Update("update user set mail=#{newMail} where user_id = #{userId}")
    int setMail(Long userId, String newMail);

    @Select("select chat_url from user where user_id = #{userId} ")
    String selectChatUrlByUserId(long id);

    @Update("update user set chat_url=#{chatUrl} where user_id = #{userId} ")
    void setchatUrl(Long userId, String chatUrl);

}
